//
//  GRJJDStatusBarNotificationViewController.m
//  GRJTolCayFrwk
//
//  Created by 易上云 on 2017/3/10.
//  Copyright © 2017年 Global Barter. All rights reserved.
//

#import "GRJJDStatusBarNotificationViewController.h"
#import "JDStatusBarNotification.h"


@interface GRJJDStatusBarNotificationViewController ()

@end

@implementation GRJJDStatusBarNotificationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"JDStatusBarNotification";
    [self setUpFiveStyle];
}

-(void)setUpFiveStyle{
    
    NSArray *array = @[@"样式一",@"样式二",@"样式三",@"样式四",@"样式五",@"样式六"];
    for (int i = 0; i<array.count; i++) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.tag = i + 100;
        button.frame = CGRectMake(i * (self.view.bounds.size.width / array.count), 200, self.view.bounds.size.width / array.count, 44);
        [button setTitle:array[i] forState:UIControlStateNormal];
        [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(hUDButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        
        [self.view addSubview:button];
    }
}

-(void)hUDButtonClick:(UIButton *)sender{
    if (sender.tag==100) {
        //[JDStatusBarNotification showWithStatus:@"测测样式" styleName:JDStatusBarStyleDefault];
        [JDStatusBarNotification showWithStatus:@"自动关闭的测试样式" dismissAfter:2.0 styleName:JDStatusBarStyleDefault];
    }else if (sender.tag==101){
        [JDStatusBarNotification showWithStatus:@"测测样式" styleName:JDStatusBarStyleError];
    }else if (sender.tag==102){
        [JDStatusBarNotification showWithStatus:@"测测样式" styleName:JDStatusBarStyleWarning];
    }else if (sender.tag==103){
        [JDStatusBarNotification showWithStatus:@"测测样式" styleName:JDStatusBarStyleSuccess];
    }else if (sender.tag==104){
        [JDStatusBarNotification showWithStatus:@"测测样式" styleName:JDStatusBarStyleDark];
    }else if (sender.tag==105){
        [JDStatusBarNotification showWithStatus:@"自定义样式" styleName:@"MyDefineStyle"];
    }
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [JDStatusBarNotification addStyleNamed:@"MyDefineStyle"
                                   prepare:^JDStatusBarStyle*(JDStatusBarStyle *style) {
                                       style.barColor = [UIColor greenColor];
                                       style.textColor = [UIColor redColor];
                                       style.font = [UIFont systemFontOfSize:12];
                                       
                                       NSShadow *shadow = [[NSShadow alloc]init];
                                       shadow.shadowColor = [UIColor blackColor];
                                       shadow.shadowBlurRadius = 2;
                                       shadow.shadowOffset = CGSizeMake(5, 5);
                                       
                                       style.textShadow = shadow;
                                       /*
                                        JDStatusBarAnimationTypeNone,    
                                        JDStatusBarAnimationTypeMove,
                                        JDStatusBarAnimationTypeBounce,
                                        JDStatusBarAnimationTypeFade
                                        */
                                       style.animationType = JDStatusBarAnimationTypeBounce;
                                       
                                       style.progressBarColor = [UIColor orangeColor];
                                       style.progressBarHeight = 5;
                                       
                                       return style;
                                   }];
}
- (IBAction)comeNotGo:(id)sender {
    [JDStatusBarNotification showWithStatus:@"来了一条单例状态栏通知"];
    
    [JDStatusBarNotification showProgress:0.8];
}
- (IBAction)letGo:(id)sender {
    [JDStatusBarNotification dismiss];
}
- (IBAction)letGoDelay:(id)sender {
    [JDStatusBarNotification dismissAfter:2];
}


- (IBAction)comeAndGo:(id)sender {
    [JDStatusBarNotification showWithStatus:@"过段时间就消失的状态栏通知" dismissAfter:3];
    
    [JDStatusBarNotification showActivityIndicator:YES indicatorStyle:UIActivityIndicatorViewStyleGray];
}

@end
